package com.huadao.cart_ccs.modle;

import android.content.Context;

import com.huadao.cart_ccs.base.BaseHttpModel;
import com.huadao.cart_ccs.data.bean.DeviceInfo;
import com.huadao.cart_ccs.data.bean.Project;
import com.huadao.cart_ccs.data.source.http.Api;
import com.huadao.cart_ccs.data.source.http.HttpFunction;
import com.huadao.cart_ccs.data.source.http.RetrofitHelper;

import io.reactivex.Observable;

public class ProjectModle extends BaseHttpModel {
    private Api api;

    public ProjectModle(Context context) {
        api=RetrofitHelper.getInstance(context).create(Api.class);
    }

    public Observable<Project> getProjectByDevid(String devId,String loginCode){
        return api.getProjectByDevid(devId,loginCode).map(new HttpFunction());
    }

    public Observable<Boolean> openProject(String projectId){
        return api.openProject(projectId).map(new HttpFunction());
    }

    public Observable<Boolean> finishReclaim(String projectId){
        return api.completeReclaim(projectId).map(new HttpFunction());
    }

    //生成随机登陆码
    public static String generateLoginCode(){
        return String.valueOf((int)(Math.random()*1000000));
    }
}